package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC2029 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public boolean stoneGameIX(int[] stones) {
            int[] mod = new int[3];
            //记录取模后能被3整除 取模为1，取模为2的个数
            for (int i : stones) {
                mod[i % 3]++;
            }
            //因为Alice先手，
            // v
            //那么Alice永远凑不出 能被3整除的数字 使得Bob认输
            //那么结果肯定是Bob赢了。
            if (mod[1] == 0 && mod[2] == 0) return false;

            //对所有能被3整除的个数 取模2
            //能被整除则说明到了Alice回合必须要找给Bob能凑出来的值
            if (mod[0] % 2 == 0) {
                return mod[1] != 0 && mod[2] != 0;
            } else {
                //反之到了Bob的回合Bob只需要满足每次多找到一个Alice所走的路不让他凑出3整除即可
                return Math.abs(mod[1] - mod[2]) > 2;
            }
        }
    }

    public void run() {
        Solution solution = new Solution();
        int[] arr = InputUtil.toIntegerArray("[1,2,3]");
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC2029 an = new LC2029();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
